function [spectrum,monicorrect] = monicorrect(x,y,e0,absnames,abslengths)
    
% return spectrum corrected for absorption between monitor and sample
% x = x-axis
% y = y-axis 
% e0 = analyzer energy [keV]
% absnames = list of absorbers as in: {'air' 'kapton'}
% abslengths = list of lengths [mm] of the x-ray path through air, kapton
%              foil, etc.
% depends on mu.m, mpr.m, myprho.m, logtable.mat

monicorrect = ones(length(y),1);
for n=1:length(absnames)
    absvec = exp(0.1*abslengths(n)*mu(absnames{n},(x*1e-3+e0)));
    monicorrect = monicorrect.*absvec;
end
monicorrect = 1./monicorrect;

spectrum = y./monicorrect;



